package com.jhhc.EngineeringSafety.Calculate.Forecast.service.impl;

//import com.jhhc.EngineeringSafety.Calculate.Forecast.dao.BDMS_YB_RESULT_AMapper;
import com.jhhc.EngineeringSafety.Calculate.Forecast.service.BDMS_YB_RESULT_A3Service;
import com.jhhc.WaterQuality.Calculate.Forecast.dao.BDMS_YB_RESULT_AMapper;
import com.jhhc.WaterQuality.Calculate.Forecast.entity.BDMS_YB_RESULT_A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * (BdmsYbResultA)表服务实现类
 *
 * @author makejava
 * @since 2023-06-20 09:23:37
 */
@Service
public class BDMS_YB_RESULT_A3ServiceImpl implements BDMS_YB_RESULT_A3Service {
    @Resource
    private BDMS_YB_RESULT_AMapper bdmsYbResultADao;

    /**
     * 通过ID查询单条数据
     *
     * @param pid 主键
     * @return 实例对象
     */
    @Override
    public BDMS_YB_RESULT_A queryById(Integer pid) {
        return this.bdmsYbResultADao.queryById(pid);
    }

    /**
     * 分页查询
     *
     * @param bdmsYbResultA 筛选条件
     * @param pageRequest   分页对象
     * @return 查询结果
     */
    @Override
    public Page<BDMS_YB_RESULT_A> queryByPage(BDMS_YB_RESULT_A bdmsYbResultA, PageRequest pageRequest) {
        long total = this.bdmsYbResultADao.count(bdmsYbResultA);
        return new PageImpl<>(this.bdmsYbResultADao.queryAllByLimit(bdmsYbResultA, pageRequest), pageRequest, total);
    }

    /**
     * 新增数据
     *
     * @param bdmsYbResultA 实例对象
     * @return 实例对象
     */
    @Override
    public BDMS_YB_RESULT_A insert(BDMS_YB_RESULT_A bdmsYbResultA) {
        this.bdmsYbResultADao.insert(bdmsYbResultA);
        return bdmsYbResultA;
    }

    /**
     * 修改数据
     *
     * @param bdmsYbResultA 实例对象
     * @return 实例对象
     */
    @Override
    public BDMS_YB_RESULT_A update(BDMS_YB_RESULT_A bdmsYbResultA) {
        this.bdmsYbResultADao.update(bdmsYbResultA);
        return this.queryById(bdmsYbResultA.getPid());
    }

    /**
     * 通过主键删除数据
     *
     * @param pid 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer pid) {
        return this.bdmsYbResultADao.deleteById(pid) > 0;
    }
}
